<extend name="Public/baseConf" />

<block name="breadcrumb"> 
	<div class="row wrapper border-bottom white-bg page-heading">
	    <div class="col-lg-4">
	        <h2>用户管理</h2>
	        <ol class="breadcrumb">
	            <li><a href="{:U('index/index')}">首页</a></li>
	            <li class="active">
	                <strong>用户管理</strong>
	            </li>
	        </ol>
	    </div>
	    <div class="col-lg-8">
            <div class="title-action">
				<span class="block pull-left">
					<a class="btn btn-white" href="{:U('add')}">
						<i class="text-navy fa fa-pencil align-top"></i>新增
					</a>
					<button class="btn btn-white ajax-post" url="{:U('changeStatus?method=resumeUser')}" target-form="ids">
						<i class="fa fa-flag"></i>启用
					</button>
			        <button class="btn btn-white ajax-post" url="{:U('changeStatus?method=forbidUser')}" target-form="ids">
						<i class="fa fa-flag"></i>禁用
					</button> 
			        <button class="btn btn-white ajax-post" url="{:U('changeStatus?method=deleteUser')}" target-form="ids">
						<i class="text-danger fa fa-trash"></i>删 除
					</button>
				</span>
				<div class="input-group">
					<input type="text" class="form-control search-input" name="nickname" value="{:I('nickname')}" placeholder="请输入用户昵称或者ID"> 
					<span class="input-group-btn"> 
						<a id="search" type="button" url="{:U('index')}" class="btn btn-primary"><i class="fa fa-search green bigger-125"></i></a> 
	                </span>
	            </div>
            </div>
        </div>
	</div> 
</block>

<block name="body">
	<div class="row">
            <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>用户列表</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <div class="table-responsive">
                    <form class="ids">
		                  <table class="table table-striped table-bordered table-hover dataTables-example" >
			                  <thead>
			                  <tr>
									<th class="center row-selected row-selected">
									<label><input type="checkbox" class="check-all" /><span class="lbl"></span></label></th>
									<th class="center">操作</th>
									<th class="center">头像</th>
									<th class="center">UID</th>
									<th class="center">昵称</th>
									<th class="center">积分</th>
									<th class="center">登录次数</th>
									<th class="center">最后登录时间</th>
									<th class="center">最后登录IP</th>
									<th class="center">状态</th>
									<th></th>
			                  </tr>
			                  </thead>
			                  <tbody>
					                <notempty name="_list">
									<volist name="_list" id="vo">
									<tr class="gradeX">
							            <td class="center">
											<label>
												<input type="checkbox" class="ids row-selected" name="id[]" value="{$vo.uid}"/>
												<span class="lbl"></span>
											</label>
										</td>
										<td class="center"><eq name="vo.status" value="1">
											<a title="禁用" class="red2 ajax-get" href="{:U('User/changeStatus?method=forbidUser&id='.$vo['uid'])}"><i class='fa fa-flag bigger-130'></i></a>&nbsp;&nbsp;
											<else/>
											<a title="启用" class="blue ajax-get" href="{:U('User/changeStatus?method=resumeUser&id='.$vo['uid'])}"><i class='fa fa-flag bigger-130'></i></a>&nbsp;&nbsp;
											</eq>
											<a title="授权" class="green authorize" href="{:U('AuthManager/group?uid='.$vo['uid'])}"> <i class='fa fa-pencil bigger-130'></i></a>&nbsp;&nbsp;
							                <a title="删除" class="red ajax-get" href="{:U('User/changeStatus?method=deleteUser&id='.$vo['uid'])}"><i class='fa fa-trash-o bigger-130'></i></a></i></a>
							            </td>
							            <td class="center">
								            <a href="{:U('User/edithead?id='.$vo['uid'])}">
								            	<img src="__ROOT__{$vo.headpath}" height="30" width="30" alt="暂无" class="img-circle"/>
								            </a>
								        </td>
										<td class="center">{$vo.uid} </td>
										<td class="center">{$vo.nickname}</td>
										<td class="center">{$vo.score}</td>
										<td class="center">{$vo.login}</td>
										<td class="center"><span>{$vo.last_login_time|time_format}</span></td>
										<td class="center"><span>{:long2ip($vo['last_login_ip'])}</span></td>
										<td class="center">{$vo.status_text}</td>
							            <td></td>
									</tr>
									</volist>
									<else/> 
									<td colspan="11" class="text-center"> aOh! 暂时还没有内容! </td>
									</notempty>
			                  </tbody>
		                  </table>
		            </form>
		            <div class="page pull-right">
				     	{$_page}
			 		</div>
                    </div>
                </div>
            </div>
        </div>
    </div>

</block>
<block name="script">
	<script src="__STATIC__/thinkbox/jquery.thinkbox.js"></script>
	<script type="text/javascript">
	//showAsDataTables('dataTables-example');
	
	//搜索功能
	$("#search").click(function(){
		var url = $(this).attr('url');
        var query  = $('.input-group').find('input').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        query = query.replace(/^&/g,'');
        if( url.indexOf('?')>0 ){
            url += '&' + query;
        }else{
            url += '?' + query;
        }
		window.location.href = url;
	});
	//回车搜索
	$(".search-input").keyup(function(e){
		if(e.keyCode === 13){
			$("#search").click();
			return false;
		}
	});
	</script>
</block>
